import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import commonjs from 'vite-plugin-commonjs';


// https://vite.dev/config/
export default defineConfig({
  base: './',
  plugins: [react(),commonjs()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
      'react': path.resolve(__dirname, './node_modules/react')
    }
  },
  optimizeDeps: {
    include: ['three', '@react-three/fiber', 'react','react-dom','rc-util/es/Dom/findDOMNode']
  },
  build: {
    commonjsOptions: {
      transformMixedEsModules: true
    },
    target: 'esnext',
    outDir: 'dist',
    rollupOptions: {
      // 默认就会打包 react 进来，除非你显式排除了
      external: [], // 确保 react 没有被排除在外
    }
  }
})
